<template>
	<div class="content">
		<view>
			<div class="weather-forecast">
				<h2>七日天气</h2>
				<view class="weather" v-for="(item,index) in weather7d" :key="index">

					<view class="text" style="font-size: 35rpx;margin-left: 3px;">
						{{item.fxDate}}
					</view>
					<view class="text" style="font-size: 35rpx;margin-left: 3px;">
						{{item.textDay}}
					</view>
					<view class="text" style="font-size: 34rpx;margin-left: 10px;">
						{{item.tempMax}}°C
					</view>
					<view class="text" style="font-size: 34rpx;margin-left: 10rpx;">
						{{item.tempMin}}°C
					</view>

					<view class="text" style="margin-left: 10rpx;">
						湿度： {{item.humidity }}%
					</view>
				</view>
			</div>
		</view>
	</div>

</template>

<script setup>
	import {
		ref
	} from "vue"

	import {
		onLoad
	} from '@dcloudio/uni-app'

	import {
		CONFIG,
		leanCloud_header
	} from '../../utils/config';

	onLoad(() => {
		getWeather()
	})
	let weather7d = ref({})

	async function getWeather() {
		let res = await uni.$get(CONFIG.hefeng_7d, {
			key: CONFIG.hefeng_key,
			location: CONFIG.hefeng_locition
		})
		if (res.code == 200) {
			weather7d.value = res.daily
			console.log(res.daily)
		}
	}
</script>

<style lang="scss" scoped>
	.weather {
		height: 100rpx;
		border: 2px solid #ccc;
		margin: 5px;
		border-radius: 5px;
		display: flex;
		justify-content: space-between;
		padding: 10rpx;
		align-items: center;
		box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
	}

	h2 {
		font-size: 40rpx;
		  font-weight: bold;
		  color: #333;
		  text-align: center;
		  width: 100%;
		  margin-bottom: 20rpx;
		  border-bottom: 2rpx solid #ccc;
		  padding-bottom: 10rpx;
	}
	.text {
	  display: flex;
	  flex-direction: column;
	  align-items: center;
	  justify-content: center;
	  color: #666;
	}
	
	.text:nth-child(1) {
	  font-weight: bold;
	  color: #333;
	}
	
	.text:nth-child(2) {
	  font-size: 30rpx;
	}
	
	.text:nth-child(3),
	.text:nth-child(4) {
	  font-size: 28rpx;
	  font-weight: bold;
	  color: #ff6600;
	}
	
	.text:nth-child(5) {
	  font-size: 26rpx;
	  color: #999;
	}
</style>